 

/**
 * User interface - Main menu
 * @author Stefan
 */
public class MainUI
{

    private ProductsUI proUI = new ProductsUI();
    private TradesUI traUI = new TradesUI();
    private CustomersUI cusUI = new CustomersUI();
    private SupplierUI supUI = new SupplierUI();
    private EmployeesUI emoUI = new EmployeesUI();
    /**
     * Start program by writing the main menu
     */
    public void startMainMenu()
    {
        boolean exit = false;
        while (!exit)
        {
            int choise = writeMainMenu();
            if (choise == 1)
            {
                startCus();
            } else if (choise == 2)
            {
                startSup();
            } else if (choise == 3)
            {
                startEmo();
            } else if (choise == 4)
            {
                startPro();
            } else if (choise == 5)
            {
                startTra();
            } else
            {
                writeEnd();
                exit = true;
            }
        }
    }

    /**
     * Write main menu
     * @return int input from keyboard
     */
    private int writeMainMenu()
    {
        System.out.println("\f *** MainMenu ***");
        System.out.println(" (1) Customers");
        System.out.println(" (2) Suppliers");
        System.out.println(" (3) Employees");
        System.out.println(" (4) Products");
        System.out.println(" (5) Trades");
        System.out.println(" (0) Close");

        return CommonUIFunctions.readInt("\n Make your choise: ");
    }

    /**
     * Print system shutdown
     */
    private void writeEnd()
    {
        System.out.println("System is shutting down!");
    }

    /**
     * Start Product UI
     */
    private void startPro()
    {
        proUI.start();
    }

    /**
     * Start Trade UI
     */
    private void startTra()
    {
        traUI.start();
    }

    /**
     * Start Customer UI
     */
    private void startCus()
    {
        cusUI.start();
    }

    /**
     * Start Supplier UI
     */
    private void startSup()
    {
        supUI.start();
    }

    /**
     * Start Employee UI
     */
    private void startEmo()
    {
        emoUI.start();
    }
}
